package com.cosmo.prototype.demo03;

public class Teacher implements Cloneable {

    private String name;

    private Student student;


    Teacher() {
        System.out.println("具体原型创建成功！");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    public Object clone() throws CloneNotSupportedException {
        System.out.println("具体原型复制成功！");
        Teacher teacher = (Teacher) super.clone();
        teacher.setStudent((Student) teacher.student.clone());
        return teacher;
    }


    @Override
    public String toString() {
        return "WuKong{" +
                "name='" + name + '\'' +
                ", student=" + student +
                '}';
    }
}
